package com.study.array;

import java.util.Arrays;

/**
 * @author ytj
 * @date 2022/1/10
 */
public class Method18 {
    public static void main(String[] args) {
        int[] nums={1,2,3,4,5,6,7};
        rotate(nums,3);
        Arrays.stream(nums).forEach(System.out::println);
    }

    public static void rotate(int[] nums, int k) {
        int length=nums.length;
        int[] newArray= Arrays.copyOf(nums,nums.length);
        for(int i=0;i<nums.length;i++){
            nums[(i+k)%length]=newArray[i];
        }

    }
}
